<?php

namespace JsonLowCode\UI;

use JsonLowCode\Schema;

/**
 * html标签组件
 * @method static Html make(mixed $children = null, string $tag = 'div') Html组件
 * @method static Html b(mixed $children = null)
 * @method static Html i(mixed $children = null)
 * @method static Html p(mixed $children = null)
 * @method static Html em(mixed $children = null)
 * @method static Html code(mixed $children = null)
 * @method static Html strong(mixed $children = null)
 * @method static Html h1(mixed $children = null)
 * @method static Html h2(mixed $children = null)
 * @method static Html h3(mixed $children = null)
 * @method static Html h4(mixed $children = null)
 * @method static Html h5(mixed $children = null)
 * @method static Html h6(mixed $children = null)
 * @method static Html hr()
 * @method static Html br()
 * @method static Html ul(mixed $children = null)
 * @method static Html ol(mixed $children = null)
 * @method static Html li(mixed $children = null)
 * @method static Html dl(mixed $children = null)
 * @method static Html dt(mixed $children = null)
 * @method static Html dd(mixed $children = null)
 * @method static Html img()
 * @method static Html audio()
 * @method static Html video()
 *
 * @method static Html form(mixed $children = null)
 * @method static Html input(mixed $children = null)
 * @method static Html textarea(mixed $children = null)
 * @method static Html select(mixed $children = null)
 * @method static Html option(mixed $children = null)
 * @method static Html label(mixed $children = null)
 * @method static Html fieldset(mixed $children = null)
 * @method static Html legend(mixed $children = null)
 *
 * @method static Html span(mixed $children = null)
 * @method static Html button(mixed $children = null)
 * @method static Html table(mixed $children = null)
 * @method static Html thead(mixed $children = null)
 * @method static Html tbody(mixed $children = null)
 * @method static Html tfoot(mixed $children = null)
 * @method static Html tr(mixed $children = null)
 * @method static Html th(mixed $children = null)
 * @method static Html td(mixed $children = null)
 *
 * @method static Html div(mixed $children = null)
 * @method static Html header(mixed $children = null)
 * @method static Html footer(mixed $children = null)
 * @method static Html nav(mixed $children = null)
 * @method static Html main(mixed $children = null)
 * @method static Html aside(mixed $children = null)
 * @method static Html article(mixed $children = null)
 * @method static Html section(mixed $children = null)
 *
 * @method static Html canvas()
 * @method static Html figure()
 * @method static Html figcaption()
 * @method static Html embed()
 * @method static Html iframe()
 * @method static Html datalist()
 * @method static Html output()
 */
class Html extends Schema
{
    protected string $componentName = "div";

    public function __construct(mixed $children = null, string $tag = 'div')
    {
        parent::__construct();
        $this->tag($tag);
        $this->children($children);
    }

    /**
     * 设置元素标签
     * @param string $tag
     * @return $this
     */
    public function tag(string $tag): static
    {
        return $this->componentName($tag);
    }

    /**
     * @param mixed|null $children
     * @return $this
     */
    public static function a(string $href, mixed $children = null): static{
        return self::make($children,'a')->prop("href",$href);
    }

    /**
     * Dynamically handle calls to the class.
     *
     * @param  string  $method
     * @param  array  $parameters
     * @return $this
     */
    public static function __callStatic(string $method, array $parameters)
    {
        return self::make($parameters[0]??null,$method);
    }
}
